#include "grid.h"

#include <gl\glfw.h>
#include "fonts/bitmap_font.h"


void _drawRectOpen(real x0,real y0,real x1,real y1) 
{ 
	glBegin(GL_LINE_LOOP);
	glVertex3f(x0,y0,0); 
	glVertex3f(x1,y0,0);
	glVertex3f(x1,y1,0); 
	glVertex3f(x0,y1,0); 
	glVertex3f(x0,y0,0);
	glEnd();

}
 
void Grid::draw()
{
	real incX = world_sizx / real(block_sx);
	real incY = world_sizy / real(block_sy);

	for(size_t i=0; i<block_sx; i++)
	{
		for(size_t j=0; j<block_sy; j++)
		{

			real screen_point_x1 = world_bounds.xmin + incX * real(i);
			real screen_point_y1 = world_bounds.ymin + incY * real(j);
			real screen_point_x2 = world_bounds.xmin + incX * real(i+1);
			real screen_point_y2 = world_bounds.ymin + incY * real(j+1);
			glColor3f(64,64,64);
			_drawRectOpen( screen_point_x1, screen_point_y1, screen_point_x2, screen_point_y2 );

			//Block &b = blockmap[i][j];
			//for(size_t k=0; k<b.numParticles; k++)
			{
				//BBox *box = b.particles[k];
				//glColor3f(255,255,255);
				//real midpx = (screen_point_x1 + screen_point_x2) / 2;
				//real midpy = (screen_point_y1 + screen_point_y2) / 2;
				//glBegin(GL_LINES);
				//glVertex3f(  midpx,  midpy, 0);
				//glVertex3f(  box->parent->centroid.x(),  box->parent->centroid.y(), 0);
				//glEnd();

				//char charBuf[16];
				//sprintf_s(charBuf, 16, "%p", (b.particles[k])->parent );
				//BitmapFont::Print(charBuf,screen_point_x1, screen_point_y1, 0xffffff);	
			}

		}
	}
}